package com.sosee.cgfw.activity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;

import com.alibaba.fastjson.JSONArray;
import com.sosee.cgfw.R;
import com.sosee.cgfw.adapter.BrandAdapter;
import com.sosee.cgfw.entity.BrandJson;
import com.sosee.cgfw.utils.Constans;
import com.sosee.cgfw.utils.Utils;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.umeng.analytics.MobclickAgent;

import java.util.List;

/**
 * Created by Thinkpad on 2016/2/15.
 * //显示所有品牌
 */
public class BrandActivity extends Activity {
    private ListView lv_brand;//品牌listview
    private BrandAdapter mAdapter;//品牌适配器
    private List<String> list;//品牌集合
    private HttpUtils httpUtils=new HttpUtils();

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_brand_list);
        initView();
        initData();
    }

    public void initView(){
        lv_brand= (ListView) findViewById(R.id.lv);
        mAdapter=new BrandAdapter(this);
        mAdapter.setList(list);
        lv_brand.setAdapter(mAdapter);
    }

    public void initData(){
        httpUtils.send(HttpRequest.HttpMethod.GET, Constans.URL_LOGO_LIST, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                List<BrandJson> bList= JSONArray.parseArray(responseInfo.result,BrandJson.class);
                if(bList!=null&&bList.size()>0){
                    Utils.showToast(bList.size()+"pinpai");
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                Utils.showToast(s);

            }
        });
    }




}
